package org.pentaho.cubic.client.perspective.fileproperties;

import org.pentaho.cubic.client.perspective.browser.IFileSummary;

public class FileItem implements IFileSummary{
	public static final String ANALYSIS_VIEW_SUFFIX = ".analysisview.xaction"; //$NON-NLS-1$
	public static final String WAQR_VIEW_SUFFIX = ".waqr.xaction"; //$NON-NLS-1$
	public static final String XACTION_SUFFIX = ".xaction"; //$NON-NLS-1$
	public static final String URL_SUFFIX = ".url"; //$NON-NLS-1$

	private String name;
	private String solution;
	private String path;
	private String lastModifiedDateStr;
	private String url;
	private String localizedName;
	private String description;
	private boolean directory;
	
	// Extract from name
	private String filetype;

	public FileItem(String name, String localizedName, String description, String solution, String path, String lastModifiedDateStr, String url, boolean directory) {
		this.name = name;
		this.localizedName = localizedName;
		this.solution = solution;
		this.path = path;
		this.lastModifiedDateStr = lastModifiedDateStr;
		this.url = url;
		this.setDescription(description);
		this.setDirectory(directory);
		
		// Extract from name
		if (filetype != null) {
			this.filetype = "Unknown";
		} else if (name.endsWith(WAQR_VIEW_SUFFIX)) {
			this.filetype = "Ad-hoc Report";
		} else if (name.endsWith(ANALYSIS_VIEW_SUFFIX)) {
			this.filetype = "Analysis View";
		} else if (name.endsWith(XACTION_SUFFIX)) {
			this.filetype = "XAction Report";
		} else if (name.endsWith(URL_SUFFIX)) {
			this.filetype = "Internet Url";
		} else {
			this.filetype = "Unknown";
		}
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSolution() {
		return solution;
	}

	public void setSolution(String solution) {
		this.solution = solution;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getLastModifiedDateStr() {
		return lastModifiedDateStr;
	}

	public void setLastModifiedDateStr(String lastModifiedDateStr) {
		this.lastModifiedDateStr = lastModifiedDateStr;
	}

	public String getURL() {
		return url;
	}

	public void setURL(String url) {
		this.url = url;
	}

	public String getLocalizedName() {
		return localizedName;
	}

	public void setLocalizedName(String localizedName) {
		this.localizedName = localizedName;
	}

	public String getFullPath() {
		return solution + path + name;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDescription() {
		return description;
	}

	public void setDirectory(boolean directory) {
		this.directory = directory;
	}

	public boolean isDirectory() {
		return directory;
	}
	
	public String getFileType() {
		return filetype;
	}

}
